import { getRoleApi } from "@/api/role";
import { addUserApi, getUserApi, uploadUserApi } from "@/api/user";
import { DeleteOutlined, EditOutlined, EllipsisOutlined, EyeOutlined, FormOutlined, PlusOutlined, ZoomInOutlined } from "@ant-design/icons";
import { ActionType, ModalForm, ProColumns, ProFormColorPicker, ProFormField, ProFormSelect, ProFormText, ProFormTextArea, ProFormUploadButton, ProFormUploadDragger, ProTable, TableDropdown } from "@ant-design/pro-components";
import { useRequest } from "ahooks";
import { Button, Drawer, Dropdown, Form, Space, Tag, message, Image, Avatar } from "antd";
import { useEffect, useRef, useState } from "react";
import dayjs from 'dayjs'
import { deleAnno, getAnnoApi, getAnnoTypeApi, uploadAnno } from "@/api/anno";
import { baseURL } from "@/api/request";
import { ChangeAvt } from "@/commpoent/changeAv";
import { DeleAdviseApi, GetAdviseApi } from "@/api/advise";
import { userStore } from "@/mobx/store";
import { history } from "umi";
import { options, zh } from "@/utils";
import { getOffterApi } from "@/api/offter";




const AdviseList = () => {
    type GithubIssueItem = getOfferListTypes

    const [roleList, setRoleList] = useState<roleTypes[]>([])
    const getRole = useRequest(getRoleApi, {
        onSuccess: (res) => {
            setRoleList(res.result)
        }
    })

    const [y, sety] = useState<getAnno>({} as getAnno)
    const [open, setOpen] = useState(false);

    const onClose = () => {
        setOpen(false);
    };
    const columns: ProColumns<GithubIssueItem>[] = [
        {
            dataIndex: 'company',
            title: '名称',
            search: false,
        },
        {
            title: '薪资',
            dataIndex: 'salarye',
            search: false,
        },
        {
            title: '进入时间',
            dataIndex: 'time',
            render: (_, record) => (
                <Space>
                    {dayjs(record.offer_time).format('YYYY-MM-DD HH:mm:ss')}
                </Space>
            )
        },
        {
            title: '所在城市',
            dataIndex: 'city',
            search: false,
        },
    {
        title: '操作',
        valueType: 'option',
        key: 'option',
        render: (text, record, _, action) => [
            <div>
                <Button type="primary" danger shape="circle" icon={<DeleteOutlined />} style={{ marginRight: '10px' }}  />
                <Button type='primary' danger shape="circle" icon={<EditOutlined />} style={{ marginRight: '10px' }}></Button>
                <Button type="primary" shape="circle" icon={<EyeOutlined />}  />
            </div>
        ],
        },
    ];
const actionRef = useRef<ActionType>();
return (
    <div>
        <ProTable<GithubIssueItem>
            columns={columns}
            actionRef={actionRef}
            cardBordered
            request={async (params = {}, sort, filter) => {
                let res = await getOffterApi(localStorage.getItem('cPhone')!)
                return {
                    data: res.result as any
                }
            }}
            editable={{
                type: 'multiple',
            }}
            columnsState={{
                persistenceKey: 'pro-table-singe-demos',
                persistenceType: 'localStorage',
                onChange(value) {
                    console.log('value: ', value);
                },
            }}
            rowKey="id"
            search={{
                labelWidth: 'auto',
            }}
            options={{
                setting: {
                    listsHeight: 400,
                },
            }}
            form={{
                // 由于配置了 transform，提交的参与与定义的不同这里需要转化一下
                syncToUrl: (values, type) => {
                    if (type === 'get') {
                        return {
                            ...values,
                            created_at: [values.startTime, values.endTime],
                        };
                    }
                    return values;
                },
            }}
            pagination={{
                pageSize: 5,
                onChange: (page) => console.log(page),
            }}
            dateFormatter="string"
            headerTitle="offer"

        />

    </div>
);
}
export default AdviseList